<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class StoreOrder extends Model
{
    protected $table = 'store_order';//
    
    protected $appends = ['status_txt','goods_list_txt','goods_count'];
    
    public function getStatusTxtAttribute(){
        switch($this->status){
        	case 0:
        		return '待付款';
        		break;
        	case 1:
        		return '已付款';
        		break;
        	case 2:
        		return '检测中';
        		break;
        	case 3:
        		return '已上传报告';
        		break;
        	case 4:
        		return '待评价';
        		break;
        	case 5:
        		return '已评价';
        		break;
        	case 6:
        		return '已取消';
        		break;
        }
    } 
    
    public function getGoodsListTxtAttribute(){
        return  json_decode($this->goods_list,true);
    } 
    
    public function getGoodsCountAttribute(){
    	$goodsArr = json_decode($this->goods_list,true);
        return  count($goodsArr);
    } 
}
